class Solution {
public:
    int search(vector<int>& nums, int target) {
        int l = 0,r = nums.size() - 1;
        while(l < r)
        {
            int mid = (l + r) / 2;
            if(nums[l] <= nums[mid])
            {
                if(nums[mid] == target)return mid;
                if(nums[mid] > target && nums[l] <= target)r = mid - 1;
                else l = mid + 1;

            }else{
                if(nums[mid] == target)return mid;
                if(nums[mid] < target && nums[r] >= target)l = mid + 1;
                else r = mid - 1;
            }


        }
        if(l == r && nums[l] == target)return l;
        return -1;


    }
};
